http	= require	('http'	);
url		= require	('url'	);
fs		= require	('fs'	);

var puerto = 1337;

var httpServer	= http.createServer (function (req, res) {
	var request	= url.parse	(req.url, true);
	var action	= request.pathname;
	
	if (action.match (/^\/current[0-9]*\.jpg/)) {
		var img = fs.readFileSync ('./current.jpg');
		console.log		(img.length);		
		res.writeHead	(200, {'Content-Type': 'image/jpeg'	});
		res.end			(img, 'binary');
	}
	
	if (action.match (/^\/chiquito[0-9]*\.jpg/)) {
		var img = fs.readFileSync ('./chiquito.jpg');
		res.writeHead	(200, {'Content-Type': 'image/jpeg'	});
		res.end			(img, 'binary');
	}
});

httpServer.listen	(puerto);
console.log			("Servidor corriendo en puerto " + puerto);
